﻿using System;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using System.ComponentModel.DataAnnotations;

namespace FutureApp.Media
{
    /// <summary>
    /// 文件基础实现
    /// </summary>
    public abstract class FileBase : Entity<Guid>, IHasCreationTime, ISoftDelete
    {
        /// <summary>
        /// <see cref="Extesion"/> 的最大长度
        /// </summary>
        public const int ExtensionMaxLength = 6;

        /// <summary>
        /// <see cref="Mime"/> 的最大长度
        /// </summary>
        public const int MimeMaxLength = 20;

        /// <summary>
        /// <see cref="Path"/> 的最大长度
        /// </summary>
        public const int PathMaxLength = 150;

        /// <summary>
        /// <see cref="Md5"/> 的最大长度
        /// </summary>
        public const int Md5MaxLength = 32;

        /// <summary>
        /// <see cref="Sha1"/> 的最大长度
        /// </summary>
        public const int Sha1MaxLength = 40;

        /// <summary>
        /// 扩展名
        /// </summary>
        [Required]
        [StringLength(ExtensionMaxLength)]
        public string Extesion { get; set; }

        /// <summary>
        /// 内容类型
        /// </summary>
        [StringLength(MimeMaxLength)]
        public string Mime { get; set; }

        /// <summary>
        /// 文件路径
        /// </summary>
        [Required]
        [StringLength(PathMaxLength)]
        public string Path { get; set; }

        /// <summary>
        /// 文件大小
        /// </summary>
        [Required]
        [Range(0, int.MaxValue)]
        public int Size { get; set; }

        /// <summary>
        /// 文件Md5码
        /// </summary>
        [StringLength(Md5MaxLength)]
        public string Md5 { get; set; }

        /// <summary>
        /// 文件Sha1码
        /// </summary>
        [StringLength(Sha1MaxLength)]
        public string Sha1 { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreationTime { get; set; }

        /// <summary>
        /// 记录是否被删除
        /// </summary>
        public bool IsDeleted { get; set; }
    }
}
